package com.dfbz.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

import java.io.IOException;
import java.util.Properties;

public class BaseDao {
    public static DruidDataSource dataSource;
    public static Properties properties;
    public static JdbcTemplate jdbcTemplate ;
    static {
        dataSource = new DruidDataSource();
        properties = new Properties();
        try {
            properties.load(BaseDao.class.getClassLoader().getResourceAsStream("jdbc.properties"));
            dataSource.setUsername(properties.getProperty("username"));
            dataSource.setPassword(properties.getProperty("password"));
            dataSource.setUrl(properties.getProperty("url"));
            dataSource.setDriverClassName(properties.getProperty("driverClass"));
            jdbcTemplate = new JdbcTemplate(dataSource);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
